<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>delete_key (Yubico)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File yubico.rb, line 219</span>
                <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_key</span>( <span class="ruby-identifier">id</span>, <span class="ruby-identifier">key_id</span>, <span class="ruby-identifier">nonce</span> )
                  <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@_key</span>
                    <span class="ruby-keyword kw">return</span> <span class="ruby-constant">E_MISSING_SECRET</span>
                  <span class="ruby-keyword kw">end</span>
                  
                  <span class="ruby-identifier">operation</span> = <span class="ruby-value str">&quot;delete_key&quot;</span>
                  <span class="ruby-identifier">mesg</span> = <span class="ruby-node">&quot;key_id=#{key_id}&amp;id=#{id}&amp;nonce=#{nonce}&amp;operation=#{operation}&quot;</span>
                  <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hmac</span>( <span class="ruby-ivar">@_id</span>, <span class="ruby-identifier">mesg</span>, <span class="ruby-value str">'sha1'</span> )
                  
                  <span class="ruby-identifier">url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;http://api.yubico.com/wsapi/delete_key?#{mesg}&amp;h=#{key}&quot;</span>)
                  <span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span> = <span class="ruby-value">80</span>
                  <span class="ruby-identifier">res</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">url</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">url</span>.<span class="ruby-identifier">port</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
                    <span class="ruby-identifier">http</span>.<span class="ruby-identifier">get</span>( <span class="ruby-identifier">url</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;?&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">query</span> )
                  }
                  
                  <span class="ruby-keyword kw">if</span>( (<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>) <span class="ruby-operator">&amp;&amp;</span> ( <span class="ruby-regexp re">/status=([\w_]+)[\s]/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>) ) )
                    <span class="ruby-ivar">@_res</span> = <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>
                    <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/status=([\w_]+)[\s]/</span>).<span class="ruby-identifier">first</span>
                  <span class="ruby-keyword kw">else</span>
                    <span class="ruby-keyword kw">return</span> <span class="ruby-constant">E_UNKNOWN_ERROR</span>
                  <span class="ruby-keyword kw">end</span>
                <span class="ruby-keyword kw">end</span></pre>
</body>
</html>